package deng.qiya.model;

import java.util.Date;

import deng.qiya.wechat.Constant;


/**
 * CREATE TABLE [dbo].[TEXT_MESSAGE](
	[ID] [int] IDENTITY(1,1) NOT NULL,
	[TO_USERNAME] [varchar](50) NULL,
	[FROM_USERNAME] [varchar](50) NULL,
	[CREATE_TIME] [varchar](50) NULL,
	[MESSAGE_TYPE] [varchar](50) NULL,
	[CONTENT] [varchar](max) NULL,
	[IS_REPLY] [varchar](1) NULL,
	[REPLY_TIME] [datetime] NULL,
	[SYSTEM_TIME] [datetime] NULL,
 */

public class TextMessage {
	private int id;
	private String toUserName;
	private String fromUserName;
	private String createTime;
	private String messageType;
	private String content;
	private String isReply;
	private Date replyTime;
	private Date systemTime;
	private String questionType;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}

	public String getToUserName() {
		return toUserName;
	}
	public void setToUserName(String toUserName) {
		this.toUserName = toUserName;
	}
	public String getFromUserName() {
		return fromUserName;
	}
	public void setFromUserName(String fromUserName) {
		this.fromUserName = fromUserName;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getMessageType() {
		return messageType;
	}
	public void setMessageType(String messageType) {
		this.messageType = messageType;
	}
	public String getContent() {
		return content;
	}
	public void setContent(String content) {
		this.content = content;
	}
	public String getIsReply() {
		return isReply;
	}
	public void setIsReply(String isReply) {
		this.isReply = isReply;
	}
	public Date getReplyTime() {
		return replyTime;
	}
	public void setReplyTime(Date replyTime) {
		this.replyTime = replyTime;
	}
	public Date getSystemTime() {
		return systemTime;
	}
	public void setSystemTime(Date systemTime) {
		this.systemTime = systemTime;
	}
	
	public String getQuestionType() {
		return questionType;
	}
	public void setQuestionType(String questionType) {
		this.questionType = questionType;
	}
	
	
	@Override
	public String toString() {
		return "TextMessage [id=" + id + ", toUserName=" + toUserName
				+ ", fromUserName=" + fromUserName + ", createTime="
				+ createTime + ", messageType=" + messageType + ", content="
				+ content + ", isReply=" + isReply + ", replyTime=" + replyTime
				+ ", systemTime=" + systemTime + ", questionType="
				+ questionType + "]";
	}
	
	
	public static TextMessage convert2TextMessage(WeChatTextMessage weChatTextMessage,String questionType){
		TextMessage tm = new TextMessage();
		tm.setContent(weChatTextMessage.getContent());
		tm.setCreateTime(weChatTextMessage.getCreateTime());
		tm.setFromUserName(weChatTextMessage.getFromUserName());
		tm.setMessageType(weChatTextMessage.getMessageType());
		tm.setToUserName(weChatTextMessage.getToUserName());
		tm.setIsReply(Constant.unReply);
		tm.setReplyTime(new Date());
		tm.setSystemTime(new Date());
		tm.setQuestionType(questionType);
		return tm;
	}
	
	public static TextMessage convert2TextMessage(WeChatLocationMessage weChatLocationMessage,String questionType){
		TextMessage tm = new TextMessage();
		tm.setContent(weChatLocationMessage.getLabel()+"/"+weChatLocationMessage.getLocationx()+"/"+weChatLocationMessage.getLocaltiony());
		tm.setCreateTime(weChatLocationMessage.getCreateTime());
		tm.setFromUserName(weChatLocationMessage.getFromUserName());
		tm.setMessageType(weChatLocationMessage.getMsgType());
		tm.setToUserName(weChatLocationMessage.getToUserName());
		tm.setIsReply(Constant.unReply);
		tm.setReplyTime(new Date());
		tm.setSystemTime(new Date());
		tm.setQuestionType(questionType);
		return tm;
	}
	
	
}
